package com.xigua.threadSafe;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2021/12/2422:57
 */
public class TicketMethod implements Runnable {

    private Integer ticke = 100;

    @Override
    public void run() {
        while (true){
            saleTicket();
        }
    }

    private synchronized void saleTicket() {
        if (ticke>0){
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"正在卖"+ticke--);
        }
    }
}
